<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="sitemesh" uri="http://www.opensymphony.com/sitemesh/decorator" %>
<!DOCTYPE html>
<!-- saved from url=(0061)http://demo.cssmoban.com/cssthemes3/yzts_15_musik/signup.html -->
<html lang="en"
      class="app js no-touch no-android chrome no-firefox no-iemobile no-ie no-ie8 no-ie10 no-ie11 no-ios no-ios7 ipad">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>用户注册</title>
</head>
<body>
<div class="bg-info dker" style="height:100% ; width:100%; position:absolute;">
    <section id="content" class="m-t-lg wrapper-md animated fadeInDown">
        <div class="container aside-xl">
            <a class="navbar-brand block" href="/index"><span class="h1 font-bold">AgileSay</span></a>
            <section class="m-b-lg">
                <header class="wrapper text-center">
                    <strong>来体验敏捷的好处吧</strong>
                </header>
                <form id="registerForm">
                    <div class="form-group">
                        <input name="realname" placeholder="真实姓名"  data-bv-notempty data-bv-notempty-message="真实姓名不能为空"
                               class="form-control rounded input-lg text-center no-border">
                    </div>
                    <div class="form-group">
                        <input name="username" placeholder="登录账号"  data-bv-notempty data-bv-notempty-message="登录账号不能为空"
                               class="form-control rounded input-lg text-center no-border">
                    </div>
                    <div class="form-group">
                        <input name="email" placeholder="登录邮箱" data-bv-notempty data-bv-notempty-message="登录邮箱不能为空"
                               type="email" class="form-control rounded input-lg text-center no-border">
                    </div>
                    <div class="form-group">
                        <input name="password" placeholder="登录密码"
                               type="password" class="form-control rounded input-lg text-center no-border">
                    </div>
                    <div class="form-group">
                        <input name="confirmPwd" placeholder="密码重复"
                               type="password" class="form-control rounded input-lg text-center no-border">
                    </div>
                    <div class="checkbox i-checks m-b">
                        <label class="m-l">
                            <input id="clause" name="clause" type="checkbox" checked="" >
                            <i></i> 同意 <a href="/">注册条款</a>
                        </label>
                    </div>
                    <button id="submit" name="submit" type="submit" class="btn btn-lg btn-warning lt b-white b-2x btn-block btn-rounded">
                        <i class="icon-arrow-right pull-right"></i><span class="m-r-n-lg">注册</span>
                    </button>
                    <div class="line line-dashed"></div>
                    <p class="text-muted text-center">
                        <small>已经注册过账号了?</small>
                    </p>
                    <a href="/login" class="btn btn-lg btn-info btn-block btn-rounded">立即登录</a>
                </form>
            </section>
        </div>
    </section>
    <!-- footer -->
    <footer id="footer">
        <div class="text-center padder clearfix">
            <p>
                <small>github开源项目，发起人apesay<br>© 2016</small>
            </p>
        </div>
    </footer>
    <!-- / footer -->
</div>

<script type="text/javascript">
    $(function () {
        $('#registerForm').bootstrapValidator({
//      message: 'This value is not valid',
//      feedbackIcons: {
//        valid: 'glyphicon glyphicon-ok',
//        invalid: 'glyphicon glyphicon-remove',
//        validating: 'glyphicon glyphicon-refresh'
//      },
            fields: {
                password: {
                    message: '登录密码还没有验证',
                    validators: {
                        notEmpty: {
                            message: '登录密码不能为空'
                        },
                        stringLength: {
                            min: 6,
                            max: 16,
                            message: '密码长度在6到16之间'
                        }
                    }
                },
                confirmPwd: {
                    message: '密码重复还没有验证',
                    validators: {
                        identical: {
                            field: 'password',
                            message: '两次密码不同请重新输入'
                        }
                    }
                }
            }
        }).on('success.form.bv', function (e) {
            // Prevent form submission
            e.preventDefault();
            // Get the form instance
            var $form = $(e.target);
            // Get the BootstrapValidator instance
            var bv = $form.data('bootstrapValidator');
            // Use Ajax to submit form data
            var data = $form.serializeArray();
            if ($("#clause").is(':checked')) {
                $.post("/check/register", data, function (data) {
                    if (data == "success") {
                        window.location.href = "/kanban/board_list";
                    } else {
                        showMsg(data);
                        document.getElementById("submit").disabled = false;//使可用
                    }
                });
            } else {
                showMsg("必须同意相关条款才可以注册");
                document.getElementById("submit").disabled = false;//使可用
            }
        });
    });
</script>
</body>
</html>